<!--
 外部来文，工作流模块
 @Author: zhanbh
 @Date: 2021-04-09
-->
<template>
  <div class="work-flow" v-loading.lock="isLoading">
    <div v-if="eventList.length">
      <event-flow :event-list="eventList">
        <template #default="{data}">
          <order-card v-if="+data.zlsjlx === 0" title="指令下发"></order-card>
          <info-card
            v-else
            :status="+data.zlsjlx === 1 ? data.qszt : data.fkzt"
            :zlsjlx="data.zlsjlx"
            :zlly="data.zlly"
            :creator="data.fbdwdm"
            :time="data.sj"
            :nr="data.nr"
          ></info-card>
        </template>
      </event-flow>
    </div>
    <no-record v-else></no-record>
  </div>
</template>

<script>
import InfoCard from '@@/event-flow/info-card';
import OrderCard from '@@/event-flow/order-card';
import EventFlow from '@@/event-flow';
import { searchZlJsFk } from '@/api/common';

export default {
  name: 'WorkFlow',
  components: {
    InfoCard,
    EventFlow,
    OrderCard
  },
  props: {},
  data() {
    return {
      isLoading: false,
      eventList: []
    };
  },
  computed: {
    flowId() {
      return this.$route.params.id || '';
    },
    zlly() {
      return this.$route.query.zlly || '1';
    }
  },
  methods: {
    fetchWorkFlows() {
      this.isLoading = true;
      searchZlJsFk({
        page: 0,
        size: 10000,
        sort: JSON.stringify({ sj: 'asc' }),
        searchCondition: JSON.stringify([
          {
            name: 'flowid',
            op: '=',
            value: this.flowId
          },
          { name: 'query_zlsjlx', value: '0,1,2', op: '=' },
          { name: 'qszt', value: '1', op: '=' },
          {
            name: 'zlly',
            op: '=',
            value: this.zlly
          }
        ])
      })
        .then(res => {
          this.eventList = res.data.content;
          this.isLoading = false;
        })
        .catch(err => {
          this.isLoading = false;
        });
    }
  },
  created() {
    this.fetchWorkFlows();
  }
};
</script>

<style scoped></style>
